#!/bin/bash
#
#/*******************************************************************
# * This file is part of the Emulex Linux Device Driver for         *
# * Fibre Channel Host Bus Adapters.                                *
# * Copyright (C) 2003-2005 Emulex.  All rights reserved.           *
# * EMULEX and SLI are trademarks of Emulex.                        *
# * www.emulex.com                                                  *
# *                                                                 *
# * This program is free software; you can redistribute it and/or   *
# * modify it under the terms of version 2 of the GNU General       *
# * Public License as published by the Free Software Foundation.    *
# * This program is distributed in the hope that it will be useful. *
# * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND          *
# * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,  *
# * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE      *
# * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
# * TO BE LEGALLY INVALID.  See the GNU General Public License for  *
# * more details, a copy of which can be found in the file COPYING  *
# * included with this package.                                     *
# *******************************************************************/
######################################################################
# 
# Startup script for the Emulex lpfcdfc driver.
# $Id: elxlpfc 2791 2006-06-09 16:00:30Z sf_support $
#
# Red Hat header
# chkconfig: 2345 00 99
# description:  Loads or unloads the Emulex lpfcdfc
#               driver.
#
# SuSE header
### BEGIN INIT INFO
# Provides: elxlpfc
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Load lpfcdfc driver.
# Description: Loads or unloads the Emulex lpfcdfc driver.
### END INIT INFO

# Source function library.
if [ -s /etc/rc.config ]; then
    . /etc/rc.config
fi

if [ -s /etc/rc.status ]; then
    . /etc/rc.status
    rc_reset
    DISTRIBUTION=suse
elif [ -s /etc/rc.d/init.d/functions ]; then
    . /etc/rc.d/init.d/functions
    DISTRIBUTION=redhat
fi

DRIVER=lpfcdfc

RETVAL=0

start() {
        MESSAGE="Starting Emulex DFC driver: "
        if [ ${DISTRIBUTION} = "suse" ]; then
	    echo -n "${MESSAGE}"
	    /sbin/modprobe ${DRIVER}
	    rc_status -v
	else
	    action $"${MESSAGE}" /sbin/modprobe ${DRIVER}
	fi
	RETVAL=$?
	return $RETVAL
}

stop() {
        MESSAGE="Stopping Emulex DFC driver: "
	if [ ${DISTRIBUTION} = "suse" ]; then
	    echo -n "${MESSAGE}"
	    /sbin/rmmod ${DRIVER}
	    rc_status -v
	else
	    action $"${MESSAGE}" /sbin/rmmod ${DRIVER}
	fi
	RETVAL=$?
	return $RETVAL
}

case "$1" in
 start)
	start
        ;;
 stop)
	stop
        ;;
 restart)
	stop
	start
	;;
 *)
        echo $"Usage: $0 {start|stop|restart}"
        exit 1
        ;;
esac

exit $RETVAL
